import 'package:flutter/material.dart';

class BlueDemoPage extends StatefulWidget{

//  @override
//  State<StatefulWidget> createState() {
//
//    return new FirstPageState();
//  }

  @override
  BluePage createState() => BluePage();

}

class BluePage extends State<BlueDemoPage>{

  int count = 0;

//  Text text = new Text("count的值为:${count}"
//  ,style: new TextStyle(
//
//      fontSize: 12,
//      color: Colors.red
//
//    ),);

  var colors = [Colors.red,Colors.black12,Colors.orange,Colors.cyan,Colors.accents];

  @override
  void initState() {
    super.initState();
    //初始化，这个函数在生命周期中只调用一次

    print("initState执行");

  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();

    //在initState之后调 Called when a dependency of this [State] object changes.
    print("didChangeDependencies执行");

  }

  @override
  void dispose() {
    super.dispose();
    //销毁
    print("dispose执行");
  }


  @override
  void didUpdateWidget(BlueDemoPage oldWidget) {
    super.didUpdateWidget(oldWidget);

    print("didUpdateWidget执行");

  }

  void _incrementCounter() {

    setState(() {

      count++;
      print("count:$count");

    });
  }


  @override
  Widget build(BuildContext context) {

    print("build执行");

    return new Scaffold(

      appBar: new AppBar(

        title: new Text('Button样式demo'),
        backgroundColor: Colors.orange[300],

      ),
      body: new SingleChildScrollView(

        child: new Column(

          children: <Widget>[

            new Padding(
              padding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
              child: new Row(
                children: <Widget>[
                  new Expanded(

                    child: new Container(
                      padding: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      margin: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      color: colors[count%4],
                      height: 100,
                      child: new Text("count的值为:$count"
                        ,style: new TextStyle(

                          fontSize: 12,
                          color: colors[(count+2)%4],

                        ),),

                    ),
                  ),

                ],


              ),
            ),

            new Padding(
              padding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
              child: new Row(
                children: <Widget>[
                  new Expanded(

                    child: new Container(
                      padding: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      margin: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      color: colors[count%4],
                      height: 100,
                      child: new FlatButton(

                        onPressed: (){

                        },
                        shape: RoundedRectangleBorder(

                          borderRadius: BorderRadius.all(Radius.circular(10)),

                        ),
                        child: new Text("圆角button"),
                        color: colors[(count+2)%4]
                        ,
                      ),

                    ),
                  ),

                ],


              ),
            ),

            new Padding(
              padding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
              child: new Row(
                children: <Widget>[
                  new Expanded(

                    child: new Container(
                      padding: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      margin: new EdgeInsets.fromLTRB(10, 10, 10, 10),
                      color: colors[count%4],
                      height: 100,
                      foregroundDecoration: new BoxDecoration(
                        color: Colors.blue,
                        border: new Border.all(color: Colors.yellow, width: 5.0,),
                        borderRadius: new BorderRadius.all(new Radius.circular(50.0)),
                        gradient: new LinearGradient(colors: [Colors.blue, Colors.green]),
                      ),
                      alignment: Alignment.center,
                      child: new Text("你好啊"),
                    ),
                  ),

                ],


              ),
            ),


          ],

        ),

      ),

      floatingActionButton: new FloatingActionButton(
        tooltip: 'Add', // used by assistive technologies
        child: new Icon(Icons.add),
        onPressed: (){

//          count = count+1;
//          print("count:$count");

          this._incrementCounter();
          print("点击事件count:$count");

        },
      ),

    );
  }

}